package com.zjm.filter.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author ZJM
 * @date 2024/4/27 17:46
 * 过滤器1
 */
public class MyFilterOneFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("前置代码1");
        System.out.println("Filter1线程：" + Thread.currentThread().getName());
        System.out.println("Filter1:"+servletRequest.getParameter("username"));
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println("Filter1线程：" + Thread.currentThread().getName());
        System.out.println("后置代码1");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
